<template>
	<view class="wrap">
		<image src="../../static/new/newLst.png" mode=""></image>
		<view class="main">
			<view class="content" v-if="goodsList.length>0" >
				<view class="dl" v-for="(item,index) in goodsList" :key="index" @click="viewPage(item.id)">
					<image class="dt" :src="item.image" mode=""></image>
					<view class="dd">
						<view class="title">{{item.name}}</view>
						<view class="times">
							<view>
								<image src="../../static/new/shijian.png" mode=""></image>
								<text>{{item.sale_time}}发布</text>
							</view>
							
						</view>
						<view class="titPri">￥<text>{{item.price}}</text></view>
					</view>
				</view>
			</view>
			<view v-else class="empty-box">
				<u-empty mode="list"></u-empty>
			</view>
		</view>

		<!-- 提示信息 -->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				queryParams: {
					page: 1,
					limit: 10,
					where: {
						scene: 0
					}
				},
				goodsList: [],
			}
		},
		onLoad(options) {
			this.queryParams.where.scene = options.type
			this.getList()
		},
		onReachBottom() {
			this.getList()
		},
		methods: {
			viewPage(ids) {
				uni.navigateTo({
					url:'/pages/newPage/shoopDetails?id='+ids
				})
			},
			getList() {
				this.$net.req('/product/getLists', this.queryParams).then(res => {
					if (res.code === 200) {
						uni.setNavigationBarTitle({
							title: res.msg || ''
						});
						if (this.queryParams.page === 1) {
							this.goodsList = res.data.list
							console.log(this.goodsList)
						} else if (res.data.list.length > 0) {
							this.goodsList = this.goodsList.concat(res.data.list)
						}

						if (res.data.list.length > 0) {
							++this.queryParams.page
						} else if (this.queryParams.page > 1) {
							this.$refs.uToast.show({
								title: '没有更多数据了！',
								type: 'info'
							})
						}
					}
				})
			},
		},
	}
</script>
<style>
	page{
		width: 100%;
		height: 100%;
		background: #292C2D;
	}
</style>
<style lang="scss" scoped>
	.wrap {
		width: 100%;
		padding: 21px 12px;
		box-sizing: border-box;
		position: relative;
		>image{
			width: 100%;
			height: 60px;
		}
		.main{
			width: 100%;
			position: absolute;
			top: 73px;
			left: 0;
			padding: 0 12px;
			box-sizing: border-box;
			.content{
				width: 100%;
				background: #FFFFFF;
				border-radius: 10px;
				padding: 20px 10px 1px;
				box-sizing: border-box;
				.dl{
					width: 100%;
					display: flex;
					margin-bottom: 20px;
					.dt{
						width: 108px;
						height: 108px;
						border-radius: 8px;
					}
					.dd{
						flex: 1;
						margin-left: 10px;
						.title{
							font-weight: bolder;
							width: 100%;
							height: 36px;
							font-size: 14px;
							font-family: HarmonyOS_Sans_SC;
							color: #2E2B2B;
							line-height: 18px;
						}
						.times{
							// width: 100%;
							display: inline-block;
							height: 24px;
							border-radius: 3px;
							border: 1px solid #FEA942;
							
							padding: 0 6px;
							box-sizing: border-box;
							margin: 5px 0 13px;
							view{
								display: flex;
								align-items: center;
								margin-top: 3px;
								image{
									width: 16px;
									height: 16px;
								}
								text{
									font-size: 12px;
									font-family: HarmonyOS_Sans_SC;
									color: #FEA942;
									margin-left: 5px;
								}
							}
							
						}
						.titPri{
							font-size: 12px;
							font-family: HarmonyOS_Sans_SC_Medium;
							color: #DFC791;
							text{
								font-size: 18px;
								font-weight: bolder;
							}
						}
					}
				}
			}
		}
		.empty-box {
			min-height: 60vh;
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
</style>
